<#include "/includes/son.ftl">


<div class="container-fluid">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-toolbar clearfix">
                    <div class="toolbar-btn-action">
                        <a class="btn btn-primary m-r-5" href="#!" id="addBtn"><i class="mdi mdi-plus"></i> 新增</a>
                    </div>
                </div>


                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>id</th>
                                <th>分类名称</th>
                                <th>商品名称</th>
                                <th>商品数量</th>
                                <th>商品价格</th>
                                <th>商品图片</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#list iPage.records as ip>
                                <tr>
                                    <td>${ip.id}</td>
                                    <td>${ip.typeName}</td>
                                    <td>${ip.shopGoods}</td>
                                    <td>${ip.shopGoodsCount}</td>
                                    <td>${(ip.shopGoodsPrice/100)?string('0.00')}元</td>
                                    <td><img src="${ip.shopGoodsImg}" style="width: 100px;height: 60px">  </td>
                                    <td>
                                        <div class="btn-group">
                                            <a id="${ip.id}" class="btn btn-xs btn-default editBtn" href="#!" title=""
                                               data-toggle="tooltip" data-original-title="编辑"><i
                                                        class="mdi mdi-pencil"></i></a>
                                            <a id="${ip.id}" class="btn btn-xs btn-default delBtn" href="#!" title=""
                                               data-toggle="tooltip" data-original-title="删除"><i
                                                        class="mdi mdi-window-close"></i></a>
                                        </div>
                                    </td>
                                </tr>
                            </#list>
                            </tbody>
                        </table>
                        <ul id="pagination1" class="pagination"></ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var pageTotal = '<#if iPage.total??>${iPage.total}</#if>' == '' ? 1 : ${iPage.total};
    var pageSize = '<#if iPage.size??>${iPage.size}</#if>' == '' ? 10 : ${iPage.size};
    var currentPage = '<#if iPage.current??>${iPage.current}</#if>' == '' ? 1 : ${iPage.current};
    showPage(pageTotal, pageSize, currentPage);
</script>
<script>
    $(function () {
        $('#addBtn').click(function () {
            window.location.href = '/goods/shopGoods/goodsEdit';
        });
        $('.editBtn').click(function () {
            window.location.href = '/goods/shopGoods/goodsEdit?id=' + $(this).attr('id');
        });
        $('.delBtn').click(function () {
            $.post('/goods/shopGoods/goodsDel', {id: $(this).attr('id')}, function (data) {
                if(data.status==200){

                    lightyear.notify(data.data, 'success', 100);
                    window.setTimeout(" window.location.href = '/goods/shopGoods/goodsList'",2000)
                }
            });
        });

    });


</script>
